"""Build dtx library"""


def scons():
    """Execute build"""
    Import('env', 'prereqs')

    env.AppendUnique(LIBPATH=[Dir('.')])

    if not prereqs.server_requested():
        return

    denv = env.Clone()

    denv.require('argobots', 'protobufc')
    denv.require('pmdk', headers_only=True)

    # dtx
    denv.Append(CPPDEFINES=['-DDAOS_PMEM_BUILD'])
    dtx = denv.d_library('dtx',
                         ['dtx_srv.c', 'dtx_rpc.c', 'dtx_resync.c', 'dtx_common.c', 'dtx_cos.c',
                          'dtx_coll.c'],
                         install_off="../..")
    denv.Install('$PREFIX/lib64/daos_srv', dtx)

    if prereqs.test_requested():
        SConscript('tests/SConscript', exports='denv')


if __name__ == "SCons.Script":
    scons()
